var pageNo=1;
var pageTotal=1;

$(function () {
    //添加

    var content=null;
    $("#form").submit(function () {

        content=$("#content").val();

        if(confirm("是否确认提交数据")) {
           if (content==null||content==''){
               alert("内容不能为空！")
               return false;
           }
            alert("添加成功！")
            return true;
        }
        alert("添加失败！")
        return false;
    });
});
/*$(function(){
    //塑胶单选按钮点击事件
    $(".myrdo:radio").css("cursor","pointer");
    $(".myrdo:radio").click(function(){
        myrdo($(this));
    });
    $(".radio-text").css("cursor","pointer");
    $(".radio-text").click(function(){
        // alert($(this).prev().val());
        $(".myrdo:radio").prop("checked",false);
        $(this).prev().prop("checked",true);
        myrdo($(this).prev());
    });

});
//塑胶单选按钮点击事件
function myrdo($this) {
    var type=$this.val();
    var name=$("#name").val();
    var typename="";
    var url="/official/productListajax?name=" + name + "&typeWebsite=" + type;
    $.post(url,function(result){
        if(result.officialWebsitesList.length!=0){
            var sttable = "";
            for (var i = 0; i < result.officialWebsitesList.length; i++) {
                if (result.officialWebsitesList[i].type==1){
                    typename="综合资讯";
                } else if(result.officialWebsitesList[i].type==2){
                    typename="塑胶官网";
                } else if(result.officialWebsitesList[i].type==3){
                    typename="名站";
                } else if(result.officialWebsitesList[i].type==4){
                    typename="推荐供应商";
                }
                sttable += "<tr>";
                sttable += "<td width='25px'>";
                sttable += "<label><input type=\"checkbox\" class=\"ace\" ><span class=\"lbl\"></span></label>";
                sttable += "</td>";
                sttable += "<td width='80px'>";
                sttable += result.officialWebsitesList[i].id;
                sttable += "</td>";
                sttable += "<td width='200px'><img src='";
                sttable += result.officialWebsitesList[i].images;
                sttable += "'/></td>";
                sttable += "<td width='100px'>";
                sttable += result.officialWebsitesList[i].name;
                sttable += "</td>";
                sttable += "<td width='150px'><a target=\"_blank\" href='";
                sttable += result.officialWebsitesList[i].href;
                sttable += "'>result.officialWebsitesList[i].href</td>";
                sttable += "<td width='100px'>";
                sttable +=typename;
                sttable += "</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialWebsitesList[i].idValue;
                sttable += "</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialWebsitesList[i].idValue2;
                sttable += "</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialWebsitesList[i].idValue3;
                sttable += "</td>";
                sttable += "<td  class=\"td-manage\">";
                sttable += " <a title=\"编辑\" onclick=\"member_edit('编辑','member-add.html','4','','510')\" href=\"javascript:;\"  class=\"btn btn-xs btn-info\" ><i class=\"icon-edit bigger-120\"></i></a>";
                sttable += " <a title=\"删除\" href=\"javascript:;\"  onclick=\"member_del(this,'1')\" class=\"btn btn-xs btn-warning\" ><i class=\"icon-trash  bigger-120\"></i></a>";
                sttable += "</td>";
                sttable += "</tr>";
            }
            $("#sertbody").html(sttable);
            pageNo = result.pageNo;
            pageTotal = result.pageTotal;
            var sttable2 = "";
            if (pageNo != pageTotal) {
                sttable2 += "<tr><td colspan='10' class='text-center'>";
                sttable2 += " <a id='downye' href='javascript:void(0);' onclick='downye();' name='down' value='下一页' style='cursor: pointer;'>下一页</a>";
                sttable2 += " <a id='meiye' href='javascript:void(0);' onclick='meiye();' style='cursor: pointer;'>尾页</a>";
                sttable2 += "</td></tr>";
            }
            $("#sertfoot").html(sttable2);
        } else {
            alert("没有数据！");
        }
    },"json");
    jj();
};*/




//搜索按钮点击事件
function subbut() {
    var content = $("#content").val();
    var url = "/official/BrandManageajax?content=" + content;
    $.post(url, function (result) {
        if (result.officialContentList.length != 0) {
            var sttable = "";
            for (var i = 0; i < result.officialContentList.length; i++) {

                sttable += "<tr>";
                sttable += "<td width='25px'>";
                sttable += "<label><input type=\"checkbox\" class=\"ace\" ><span class=\"lbl\"></span></label>";
                sttable += "</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialContentList[i].id;
                sttable += "</td>";
                sttable += "<td width='120px'>";
                sttable += result.officialContentList[i].content;
                sttable += "</td>";
                sttable += "<td width='150px'><a target=\"_blank\" href='";
                sttable += result.officialContentList[i].contentlink;
                sttable += "'>"+result.officialContentList[i].contentlink+"</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialContentList[i].websiteId;
                sttable += "</td>";
                sttable += "<td  class=\"td-manage\">";
                sttable += " <a title=\"编辑\" onclick=\"member_edit('编辑','member-add.html','4','','510')\" href=\"javascript:;\"  class=\"btn btn-xs btn-info\" ><i class=\"icon-edit bigger-120\"></i></a>";
                sttable += " <a title=\"删除\" href=\"javascript:;\"  onclick=\"member_del(this,'1')\" class=\"btn btn-xs btn-warning\" ><i class=\"icon-trash  bigger-120\"></i></a>";
                sttable += "</td>";
                sttable += "</tr>";
            }
            $("#sertbody").html(sttable);
            pageNo = result.pageNo;
            pageTotal = result.pageTotal;
            var sttable2 = "";
            if (pageNo != pageTotal) {
                sttable2 += "<tr><td colspan='6' class='text-center'>";
                sttable2 += " <a id='downye' href='javascript:void(0);' onclick='downye();' name='down' value='下一页' style='cursor: pointer;'>下一页</a>";
                sttable2 += " <a id='meiye' href='javascript:void(0);' onclick='meiye();' style='cursor: pointer;'>尾页</a>";
                sttable2 += "</td></tr>";
            }
            $("#sertfoot").html(sttable2);
        } else {
            alert("没有数据！");
        }
    }, "json");
    jj();
};

//为动态添加的元素重新绑定事件
function jj() {
    $("#suoye").on("click", "suoye();");
    $("#upye").on("click", "upye();");
    $("#downye").on("click", "downye();");
    $("#meiye").on("click", "meiye();");
}

//首页点击事件
function suoye() {
    var content = $("#content").val();
    var url = "/official/BrandManageajax?pageNo=1&content=" + content;
    $.post(url, function (result) {
        if (result.officialContentList.length != 0) {
            var sttable = "";
            for (var i = 0; i < result.officialContentList.length; i++) {

                sttable += "<tr>";
                sttable += "<td width='25px'>";
                sttable += "<label><input type=\"checkbox\" class=\"ace\" ><span class=\"lbl\"></span></label>";
                sttable += "</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialContentList[i].id;
                sttable += "</td>";
                sttable += "<td width='120px'>";
                sttable += result.officialContentList[i].content;
                sttable += "</td>";
                sttable += "<td width='150px'><a target=\"_blank\" href='";
                sttable += result.officialContentList[i].contentlink;
                sttable += "'>"+result.officialContentList[i].contentlink+"</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialContentList[i].websiteId;
                sttable += "</td>";
                sttable += "<td  class=\"td-manage\">";
                sttable += " <a title=\"编辑\" onclick=\"member_edit('编辑','member-add.html','4','','510')\" href=\"javascript:;\"  class=\"btn btn-xs btn-info\" ><i class=\"icon-edit bigger-120\"></i></a>";
                sttable += " <a title=\"删除\" href=\"javascript:;\"  onclick=\"member_del(this,'1')\" class=\"btn btn-xs btn-warning\" ><i class=\"icon-trash  bigger-120\"></i></a>";
                sttable += "</td>";
                sttable += "</tr>";
            }
            $("#sertbody").html(sttable);
            pageNo = result.pageNo;
            pageTotal = result.pageTotal;
            var sttable2 = "";
            sttable2 += "<tr><td colspan='6' class='text-center'>";
            sttable2 += " <a id='downye' href='javascript:void(0);' onclick='downye();' name='down' value='下一页' style='cursor: pointer;'>下一页</a>";
            sttable2 += " <a id='meiye' href='javascript:void(0);' onclick='meiye();' style='cursor: pointer;'>尾页</a>";
            sttable2 += "</td></tr>";
            $("#sertfoot").html(sttable2);
        } else {
            alert("没有数据！");
        }
    }, "json");
    jj();
};

//上一页点击事件
function upye() {
    var content = $("#content").val();
    var url = "/official/BrandManageajax?pageNo=" + (pageNo - 1) + "&content=" + content;
    $.post(url, function (result) {
        if (result.officialContentList.length != 0) {
            var sttable = "";
            for (var i = 0; i < result.officialContentList.length; i++) {

                sttable += "<tr>";
                sttable += "<td width='25px'>";
                sttable += "<label><input type=\"checkbox\" class=\"ace\" ><span class=\"lbl\"></span></label>";
                sttable += "</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialContentList[i].id;
                sttable += "</td>";
                sttable += "<td width='120px'>";
                sttable += result.officialContentList[i].content;
                sttable += "</td>";
                sttable += "<td width='150px'><a target=\"_blank\" href='";
                sttable += result.officialContentList[i].contentlink;
                sttable += "'>"+result.officialContentList[i].contentlink+"</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialContentList[i].websiteId;
                sttable += "</td>";
                sttable += "<td  class=\"td-manage\">";
                sttable += " <a title=\"编辑\" onclick=\"member_edit('编辑','member-add.html','4','','510')\" href=\"javascript:;\"  class=\"btn btn-xs btn-info\" ><i class=\"icon-edit bigger-120\"></i></a>";
                sttable += " <a title=\"删除\" href=\"javascript:;\"  onclick=\"member_del(this,'1')\" class=\"btn btn-xs btn-warning\" ><i class=\"icon-trash  bigger-120\"></i></a>";
                sttable += "</td>";
                sttable += "</tr>";
            }
            $("#sertbody").html(sttable);
            var sttable2 = "";
            sttable2 += "<tr><td colspan='6' class='text-center'>";
            pageNo = result.pageNo;
            pageTotal = result.pageTotal;
            if (pageNo != 1) {
                sttable2 += " <a id='suoye' href='javascript:void(0);' onclick='suoye();' style='cursor: pointer;'>首页</a>";
                sttable2 += " <a id='upye' href='javascript:void(0);' onclick='upye();' style='cursor: pointer;'>上一页</a>";
            }
            sttable2 += " <a id='downye' href='javascript:void(0);' onclick='downye();' name='down' value='下一页' style='cursor: pointer;'>下一页</a>";
            sttable2 += " <a id='meiye' href='javascript:void(0);' onclick='meiye();' style='cursor: pointer;'>尾页</a>";
            sttable2 += "</td></tr>";
            $("#sertfoot").html(sttable2);
        } else {
            alert("没有数据！");
        }
    }, "json");
    jj();
};

//下一页点击事件
function downye() {
    var content = $("#content").val();
    var url = "/official/BrandManageajax?pageNo=" + (pageNo + 1) + "&content=" + content;
    $.post(url, function (result) {
        if (result.officialContentList.length != 0) {
            var sttable = "";
            for (var i = 0; i < result.officialContentList.length; i++) {

                sttable += "<tr>";
                sttable += "<td width='25px'>";
                sttable += "<label><input type=\"checkbox\" class=\"ace\" ><span class=\"lbl\"></span></label>";
                sttable += "</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialContentList[i].id;
                sttable += "</td>";
                sttable += "<td width='120px'>";
                sttable += result.officialContentList[i].content;
                sttable += "</td>";
                sttable += "<td width='150px'><a target=\"_blank\" href='";
                sttable += result.officialContentList[i].contentlink;
                sttable += "'>"+result.officialContentList[i].contentlink+"</td>";
                sttable += "<td width='100px'>";
                sttable += result.officialContentList[i].websiteId;
                sttable += "</td>";
                sttable += "<td  class=\"td-manage\">";
                sttable += " <a title=\"编辑\" onclick=\"member_edit('编辑','member-add.html','4','','510')\" href=\"javascript:;\"  class=\"btn btn-xs btn-info\" ><i class=\"icon-edit bigger-120\"></i></a>";
                sttable += " <a title=\"删除\" href=\"javascript:;\"  onclick=\"member_del(this,'1')\" class=\"btn btn-xs btn-warning\" ><i class=\"icon-trash  bigger-120\"></i></a>";
                sttable += "</td>";
                sttable += "</tr>";
            }
            $("#sertbody").html(sttable);
            var sttable2 = "";
            sttable2 += "<tr><td colspan='6' class='text-center'>";
            sttable2 += " <a id='suoye' href='javascript:void(0);' onclick='suoye();' style='cursor: pointer;'>首页</a>";
            sttable2 += " <a id='upye' href='javascript:void(0);' onclick='upye();' style='cursor: pointer;'>上一页</a>";
            pageNo = result.pageNo;
            pageTotal = result.pageTotal;
            if (pageNo != pageTotal) {
                sttable2 += " <a id='downye' href='javascript:void(0);' onclick='downye();' name='down' value='下一页' style='cursor: pointer;'>下一页</a>";
                sttable2 += " <a id='meiye' href='javascript:void(0);' onclick='meiye();' style='cursor: pointer;'>尾页</a>";
            }
            sttable2 += "</td></tr>";
            $("#sertfoot").html(sttable2);
        } else {
            alert("没有数据！");
        }
    }, "json");
    jj();
}

//尾页点击事件
function meiye() {
    var content = $("#content").val();

    var url = "/official/BrandManageajax?pageNo=" + pageTotal + "&content=" + content;
    $.post(url, function (result1) {
        pageTotal = result1.pageTotal;
        url = "/official/BrandManageajax?pageNo=" + pageTotal + "&content=" + content;
        $.post(url, function (result) {

            if (result.officialContentList.length != 0) {
                var sttable = "";
                for (var i = 0; i < result.officialContentList.length; i++) {

                    sttable += "<tr>";
                    sttable += "<td width='25px'>";
                    sttable += "<label><input type=\"checkbox\" class=\"ace\" ><span class=\"lbl\"></span></label>";
                    sttable += "</td>";
                    sttable += "<td width='100px'>";
                    sttable += result.officialContentList[i].id;
                    sttable += "</td>";
                    sttable += "<td width='120px'>";
                    sttable += result.officialContentList[i].content;
                    sttable += "</td>";
                    sttable += "<td width='150px'><a target=\"_blank\" href='";
                    sttable += result.officialContentList[i].contentlink;
                    sttable += "'>"+result.officialContentList[i].contentlink+"</td>";
                    sttable += "<td width='100px'>";
                    sttable += result.officialContentList[i].websiteId;
                    sttable += "</td>";
                    sttable += "<td  class=\"td-manage\">";
                    sttable += " <a title=\"编辑\" onclick=\"member_edit('编辑','member-add.html','4','','510')\" href=\"javascript:;\"  class=\"btn btn-xs btn-info\" ><i class=\"icon-edit bigger-120\"></i></a>";
                    sttable += " <a title=\"删除\" href=\"javascript:;\"  onclick=\"member_del(this,'1')\" class=\"btn btn-xs btn-warning\" ><i class=\"icon-trash  bigger-120\"></i></a>";
                    sttable += "</td>";
                    sttable += "</tr>";
                }
                $("#sertbody").html(sttable);
                pageNo = result.pageNo;
                pageTotal = result.pageTotal;
                var sttable2 = "";
                sttable2 += "<tr><td colspan='6' class='text-center'>";
                sttable2 += " <a id='suoye' href='javascript:void(0);' onclick='suoye();' style='cursor: pointer;'>首页</a>";
                sttable2 += " <a id='upye' href='javascript:void(0);' onclick='upye();' style='cursor: pointer;'>上一页</a>";
                sttable2 += "</td></tr>";
                $("#sertfoot").html(sttable2);
            } else {
                alert("没有数据！");
            }
        }, "json");
    }, "json");
    jj();
};


